<?php
//header("content-type: text/xml; charset=utf-8");

$long = $_GET['long'];
$lat = $_GET['lat'];
$oid = $_GET['oid'];

//Verbindung zur Datenbank + Abfrage
mysql_connect('localhost', 'locawa', 'hurz');
mysql_select_db('locawa');

$sql = "SELECT longitude, latitude, description, opening, pic, str, nr , plz, city FROM locations".
	   "  JOIN addresses ON (locations.addressID = addresses.addressID)".
	   "  WHERE locations.ID = '".$oid."'";
	   
$result = mysql_query($sql);
$row = mysql_fetch_array($result);

$Ulon = $long;
$Ulat = $lat;
$POIlon = $row['longitude'];
$POIlat = $row['latitude'];

$distance = 34.23;

$document = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$document .= "<locawa>\r\n";

$document .= " <poidetail STNR=\"".$row['str']." ".$row['nr']."\" ADDRESS=\"".$row['plz']." ".$row['city']."\" DIS=\"".$distance.
			 "\" DESC=\"".$row['description']."\" OPENING=\"".$row['opening']."\" IMAGE=\"img/".$row['pic']."\" MAP=\"osm.php?Ulon=".$Ulon."&Ulat=".$Ulat."&POIlon=".$POIlon."&POIlat=".$POIlat."\" />\n".
			 "</locawa>";

$document = utf8_encode($document);

echo $document;

//global $Ulon, $Ulat, $POIlon, $POIlat;

//OSM Karte einbinden
//require_once('osm.php');